/**
 * Data.java
 * Version: 1.0
 * Created in 06/08/2013
 * Created by: Gerson Groth
 * 
 * Copyright
 */
package webcrawler.activities.data;

import org.apache.log4j.Logger;

import webcrawler.activities.view.utils.Browsers;
import webcrawler.activities.webcrawler.WebCrawler;

/**
 * The Class Data.
 *
 * @author Gerson Groth
 */
public class Data {
	
	/** The logger. */
	private Logger logger = Logger.getLogger(Data.class);
	
	/** The instance. */
	private static Data INSTANCE = new Data();

	/** The tcx folder. */
	private String tcxFolder;
	
	/** The xml folder. */
	private String xmlFolder;
	
	/** The gpx folder. */
	private String gpxFolder;
	
	/** The keyword. */
	private String keyword;
	
	/** The location. */
	private String location;
	
	/** The activity type. */
	private String activityType;
	
	/** The event type. */
	private String eventType;
	
	/** The time period. */
	private String timePeriod;
	
	/** The date init. */
	private String dateInit;
	
	/** The date end. */
	private String dateEnd;
	
	/** The distance init. */
	private String distanceInit;
	
	/** The distance end. */
	private String distanceEnd;
	
	/** The time init. */
	private String timeInit;
	
	/** The time end. */
	private String timeEnd;
	
	/** The elevation init. */
	private String elevationInit;
	
	/** The elevation end. */
	private String elevationEnd;
	
	/** The display name. */
	private String displayName;
	
	/** The my activities only. */
	private boolean myActivitiesOnly;
	
	/** The user name. */
	private String userName = "";
	
	/** The password. */
	private String password = "";
	
	/** The login. */
	private boolean login;
	
	/** The download tcx. */
	private boolean downloadTcx;
	
	/** The download gpx. */
	private boolean downloadGpx;
	
	/** The download xml. */
	private boolean downloadXml;
	
	/** The browse. */
	private Browsers browser;


	public Data(){
		this.browser = Browsers.FIREFOX;
		this.tcxFolder = "";
		this.xmlFolder = "";
		this.gpxFolder = "";
		this.keyword = "";
		this.location = "";
		this.activityType = "";
		this.eventType = "";
		this.timePeriod = "";
		this.dateInit = "";
		this.dateEnd = "";
		this.distanceInit = "";
		this.distanceEnd = "";
		this.timeInit = "";
		this.timeEnd = "";
		this.elevationInit = "";
		this.elevationEnd = "";
		this.displayName = "";
		this.myActivitiesOnly = false;
		this.userName = "";
		this.password = "";
		this.login = false;
		this.downloadTcx = true;
		this.downloadGpx = true;
		this.downloadXml = true;
	}
	
	
	/**
	 * Gets the tcx folder.
	 *
	 * @return the tcx folder
	 */
	public String getTcxFolder() {
		return tcxFolder;
	}

	
	/**
	 * Sets the tcx folder.
	 *
	 * @param tcxFolder the new tcx folder
	 */
	public void setTcxFolder(String tcxFolder) {
		this.tcxFolder = endsWith(tcxFolder);
	}
	
	/**
	 * Ends with.
	 *
	 * @param s the s
	 * @return the string
	 */
	public String endsWith(String s){
		if(!"".equals(s) && s != null && !s.endsWith("/")){
			s += "/";
		}
		return s;
	}

	/**
	 * Gets the xml folder.
	 *
	 * @return the xml folder
	 */
	public String getXmlFolder() {
		return xmlFolder;
	}

	/**
	 * Sets the xml folder.
	 *
	 * @param xmlFolder the new xml folder
	 */
	public void setXmlFolder(String xmlFolder) {
		this.xmlFolder = endsWith(xmlFolder);
	}

	/**
	 * Gets the keyword.
	 *
	 * @return the keyword
	 */
	public String getKeyword() {
		return keyword;
	}

	/**
	 * Sets the keyword.
	 *
	 * @param keyword the new keyword
	 */
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	/**
	 * Gets the location.
	 *
	 * @return the location
	 */
	public String getLocation() {
		return location;
	}

	/**
	 * Sets the location.
	 *
	 * @param location the new location
	 */
	public void setLocation(String location) {
		this.location = location;
	}

	/**
	 * Gets the activity type.
	 *
	 * @return the activity type
	 */
	public String getActivityType() {
		return activityType;
	}

	/**
	 * Sets the activity type.
	 *
	 * @param activityType the new activity type
	 */
	public void setActivityType(String activityType) {
		this.activityType = activityType;
	}

	/**
	 * Gets the event type.
	 *
	 * @return the event type
	 */
	public String getEventType() {
		return eventType;
	}

	/**
	 * Sets the event type.
	 *
	 * @param eventType the new event type
	 */
	public void setEventType(String eventType) {
		this.eventType = eventType;
	}

	/**
	 * Gets the time period.
	 *
	 * @return the time period
	 */
	public String getTimePeriod() {
		return timePeriod;
	}

	/**
	 * Sets the time period.
	 *
	 * @param timePeriod the new time period
	 */
	public void setTimePeriod(String timePeriod) {
		this.timePeriod = timePeriod;
	}

	/**
	 * Gets the date init.
	 *
	 * @return the date init
	 */
	public String getDateInit() {
		return dateInit;
	}

	/**
	 * Sets the date init.
	 *
	 * @param dateInit the new date init
	 */
	public void setDateInit(String dateInit) {
		this.dateInit = dateInit;
	}

	/**
	 * Gets the date end.
	 *
	 * @return the date end
	 */
	public String getDateEnd() {
		return dateEnd;
	}

	/**
	 * Sets the date end.
	 *
	 * @param dateEnd the new date end
	 */
	public void setDateEnd(String dateEnd) {
		this.dateEnd = dateEnd;
	}

	/**
	 * Gets the distance init.
	 *
	 * @return the distance init
	 */
	public String getDistanceInit() {
		return distanceInit;
	}

	/**
	 * Sets the distance init.
	 *
	 * @param distanceInit the new distance init
	 */
	public void setDistanceInit(String distanceInit) {
		this.distanceInit = distanceInit;
	}

	/**
	 * Gets the distance end.
	 *
	 * @return the distance end
	 */
	public String getDistanceEnd() {
		return distanceEnd;
	}

	/**
	 * Sets the distance end.
	 *
	 * @param distanceEnd the new distance end
	 */
	public void setDistanceEnd(String distanceEnd) {
		this.distanceEnd = distanceEnd;
	}

	/**
	 * Gets the time init.
	 *
	 * @return the time init
	 */
	public String getTimeInit() {
		return timeInit;
	}

	/**
	 * Sets the time init.
	 *
	 * @param timeInit the new time init
	 */
	public void setTimeInit(String timeInit) {
		this.timeInit = timeInit;
	}

	/**
	 * Gets the time end.
	 *
	 * @return the time end
	 */
	public String getTimeEnd() {
		return timeEnd;
	}

	/**
	 * Sets the time end.
	 *
	 * @param timeEnd the new time end
	 */
	public void setTimeEnd(String timeEnd) {
		this.timeEnd = timeEnd;
	}

	/**
	 * Gets the elevation init.
	 *
	 * @return the elevation init
	 */
	public String getElevationInit() {
		return elevationInit;
	}

	/**
	 * Sets the elevation init.
	 *
	 * @param elevationInit the new elevation init
	 */
	public void setElevationInit(String elevationInit) {
		this.elevationInit = elevationInit;
	}

	/**
	 * Gets the elevation end.
	 *
	 * @return the elevation end
	 */
	public String getElevationEnd() {
		return elevationEnd;
	}

	/**
	 * Sets the elevation end.
	 *
	 * @param elevationEnd the new elevation end
	 */
	public void setElevationEnd(String elevationEnd) {
		this.elevationEnd = elevationEnd;
	}

	/**
	 * Gets the display name.
	 *
	 * @return the display name
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * Sets the display name.
	 *
	 * @param displayName the new display name
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	/**
	 * Checks if is my activities only.
	 *
	 * @return true, if is my activities only
	 */
	public boolean isMyActivitiesOnly() {
		return myActivitiesOnly;
	}

	/**
	 * Sets the my activities only.
	 *
	 * @param myActivitiesOnly the new my activities only
	 */
	public void setMyActivitiesOnly(boolean myActivitiesOnly) {
		this.myActivitiesOnly = myActivitiesOnly;
	}

	/**
	 * Gets the user name.
	 *
	 * @return the user name
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * Sets the user name.
	 *
	 * @param userName the new user name
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * Gets the password.
	 *
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Sets the password.
	 *
	 * @param password the new password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Gets the single instance of Data.
	 *
	 * @return single instance of Data
	 */
	public static Data getInstance() {
		return INSTANCE;
	}

	/**
	 * Gets the gpx folder.
	 *
	 * @return the gpx folder
	 */
	public String getGpxFolder() {
		return gpxFolder;
	}

	/**
	 * Sets the gpx folder.
	 *
	 * @param gpxFolder the new gpx folder
	 */
	public void setGpxFolder(String gpxFolder) {
		this.gpxFolder = endsWith(gpxFolder);
	}

	/**
	 * Checks if is login.
	 *
	 * @return true, if is login
	 */
	public boolean isLogin() {
		return login;
	}

	/**
	 * Sets the login.
	 *
	 * @param login the new login
	 */
	public void setLogin(boolean login) {
		this.login = login;
	}

	/**
	 * Sets the download xml.
	 *
	 * @param selected the new download xml
	 */
	public void setDownloadXml(boolean selected) {
		this.downloadXml = selected;
	}

	/**
	 * Sets the download gpx.
	 *
	 * @param selected the new download gpx
	 */
	public void setDownloadGpx(boolean selected) {
		this.downloadGpx = selected;

	}

	/**
	 * Sets the download tcx.
	 *
	 * @param selected the new download tcx
	 */
	public void setDownloadTcx(boolean selected) {
		this.downloadTcx = selected;

	}

	/**
	 * Checks if is download xml.
	 *
	 * @return true, if is download xml
	 */
	public boolean isDownloadXml() {
		return downloadXml;
	}

	/**
	 * Sets the dowload xml.
	 *
	 * @param dowloadXml the new dowload xml
	 */
	public void setDowloadXml(boolean dowloadXml) {
		this.downloadXml = dowloadXml;
	}

	/**
	 * Checks if is download tcx.
	 *
	 * @return true, if is download tcx
	 */
	public boolean isDownloadTcx() {
		return downloadTcx;
	}

	/**
	 * Checks if is download gpx.
	 *
	 * @return true, if is download gpx
	 */
	public boolean isDownloadGpx() {
		return downloadGpx;
	}
	
	/**
	 * Gets the browse.
	 *
	 * @return the browse
	 */
	public Browsers getBrowser() {
		return browser;
	}

	/**
	 * Sets the browse.
	 *
	 * @param browse the new browse
	 */
	public void setBrowser(Browsers browse) {
		this.browser = browse;
	}

	/**
	 * Gets the clone.
	 *
	 * @return the clone
	 */
	public Data getClone() {
		
		Data newData = new Data();
		
		newData.setTcxFolder(this.tcxFolder);
		newData.setXmlFolder(this.xmlFolder);
		newData.setGpxFolder(this.gpxFolder);
		newData.setKeyword(this.keyword);
		newData.setLocation(this.location);
		newData.setActivityType(this.activityType);
		newData.setEventType(this.eventType);
		newData.setTimePeriod(this.timePeriod);	
		newData.setDateInit(this.dateInit);
		newData.setDateEnd(this.dateEnd);
		newData.setDistanceInit(this.distanceInit);
		newData.setDistanceEnd(this.distanceEnd);
		newData.setTimeInit(this.timeInit);
		newData.setTimeEnd(this.timeEnd);
		newData.setElevationInit(this.elevationInit);
		newData.setElevationEnd(this.elevationEnd);
		newData.setDisplayName(this.displayName);
		newData.setMyActivitiesOnly(this.myActivitiesOnly);
		newData.setUserName(this.userName);
		newData.setPassword(this.password);
		newData.setLogin(this.login);
		newData.setDownloadTcx(this.downloadTcx);
		newData.setDownloadGpx(this.downloadGpx);
		newData.setDownloadXml(this.downloadXml);	
		newData.setBrowser(this.browser);
		
		return newData;
	}

	

}
